package main

import "fmt"

func main() {
	fmt.Println(trainingPlan(&ListNode{2, &ListNode{4, &ListNode{7, &ListNode{8, nil}}}}, 1))
}

//type ListNode struct {
//	Val  int
//	Next *ListNode
//}

func trainingPlan(head *ListNode, cnt int) *ListNode {
	if head == nil {
		return nil
	}
	res := []*ListNode{}
	for head != nil {
		res = append(res, head)
		head = head.Next
	}
	l := len(res)
	if l >= cnt {
		return res[l-cnt]
	}
	return nil
}
